package org.chuanyang.mm;

import java.util.Calendar;

import org.chuanyang.mm.utils.HandleDateAndTime;

import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.widget.TimePicker;

public class EditTimeDialog {

	private HandleDateAndTime dt;
	private Context context;
	private Operate operate;

	public EditTimeDialog(Context context) {
		this.context = context;
		this.operate = (Operate) context;
		init();
	}

	private void init() {
		dt = new HandleDateAndTime();
	}

	public void createTimeDialog() {
		OnTimeSetListener callBack = new OnTimeSetListener() {

			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				dt.calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
				dt.calendar.set(Calendar.MINUTE, minute);
				operate.refreshTime(dt.getSetTime());
				
			}
		};
		new TimePickerDialog(context, callBack,
				dt.calendar.get(Calendar.HOUR_OF_DAY),
				dt.calendar.get(Calendar.MINUTE), true).show();
	}
}
